/*---------------------------------------------------------------------*\
    This program comes with ABSOLUTELY NO WARRANTY!
    This is free software, and you are welcome to redistribute it
    under the conditions of the GPLv3.
\*---------------------------------------------------------------------*/

#include  <iostream>
#include  <unistd.h>

extern "C" {
#include  "gpiofnc.h"
}

/* --------------------------------------------------------------------
*/
int  main(int  argc,  char  **argv)
{  
    int  g,rep;

    if (gpioInit() > 0)
      return 1;

    while (1) {
      std::string cmd;
      int         arg;
      std::cout << "ok" << std::endl;
      std::cin >> cmd >> arg;
      if (std::cin.fail())
        return 0;
      if (cmd == "MO")
        gpioOutMode(arg);
      else if (cmd == "S1")
        gpioSet(arg,1);
      else if (cmd == "S0")
        gpioSet(arg,0);
      else if (cmd == "BR")
        usleep(1000*arg);
      else {
        std::cerr << "unknown command" << std::endl;
        return 1;
      }
    }
    return  0;
}
